#include"IFieldPyramidKernel.hpp"


_NNU_DGGS_BEGIN
namespace Kernel {
    _DGGS_Interface IDGGSKernel;
}
using namespace Kernel;

using namespace Base;
namespace FieldPyramid{

    /// <summary>
    /// 多分辨率Field组织类
    /// </summary>
    class DGGSFieldPyramidImpl: public IFieldPyramidKernel{

    private:
        FieldPyramidSet     _pyramidSet;                                 //多分辨率参数
        IDGGSKernel*        _pKernel= nullptr;                           //格网编码基础功能

    public:
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="pyramidSet">多分辨率参数</param>
        void init(FieldPyramidSet &pyramidSet)override;

        /// <summary>
        /// 卸载
        /// </summary>
        void release()override;

        /// <summary>
        /// 根据瓦片编码获取瓦片的空间范围
        /// </summary>
        /// <param name="tileCodes">瓦片编码</param>
        /// <param name="spaceBBox">空间范围</param>
        /// <returns></returns>
        bool getTileSpaceBound(DGGSTileCode tileCode, DGGSSpaceBBox &spaceBBox)override;

        /// <summary>
        /// 获取指定层级在当前范围内的所有瓦片
        /// </summary>
        /// <param name="tileCodes">瓦片编码组</param>
        /// <param name="tileCount">瓦片数量</param>
        /// <param name="level">层级</param>
        /// <param name="spaceBBox">空间范围</param>
        /// <returns></returns>
        bool getTileCodes(DGGSSpaceBBox spaceBBox,int level,DGGSTileCode *&tileCodes,int & tileCount)override;

        /// <summary>
        /// 根据瓦片编码获取瓦片的格网范围
        /// </summary>
        /// <param name="tileCodes">瓦片编码</param>
        /// <param name="tileBound">格网包围盒范围</param>
        /// <returns></returns>
        bool getTileGridBound(DGGSTileCode tileCode, DGGridBBox &gridBBox)override;

        /// <summary>
        /// 格网编码转瓦片编码
        /// </summary>
        /// <param name="elementCode">格网编码</param>
        /// <param name="tileCode">瓦片编码</param>
        /// <returns></returns>
        bool gridCodeToTileCode(DGGSElementCode elementCode, DGGSTileCode &tileCode)override;

        /// <summary>
        /// 拓扑查询
        /// </summary>
        /// <param name="topoType">瓦片拓扑类型</param>
        /// <param name="tileCode">瓦片编码</param>
        /// <param name="result">结果</param>
        /// <param name="resultCount">结果数量</param>
        /// <returns></returns>
        bool query(DGGSTileTopoType topoType,DGGSTileCode tileCode,DGGSTileCode *&result,int &resultCount)override;

    private:
        /// <summary>
        /// 获取瓦片的父瓦片
        /// </summary>
        /// <param name="tileCode">瓦片编码</param>
        /// <param name="result">结果</param>
        /// <param name="resultCount">结果数量</param>
        /// <returns></returns>
        bool getParent(DGGSTileCode tileCode, DGGSTileCode*&result, int &resultCount);

        /// <summary>
        /// 获取瓦片的子瓦片
        /// </summary>
        /// <param name="tileCode">瓦片编码</param>
        /// <param name="result">结果</param>
        /// <param name="resultCount">结果数量</param>
        /// <returns></returns>
        bool getChildren(DGGSTileCode tileCode, DGGSTileCode*&result, int &resultCount);

        /// <summary>
        /// 获取瓦片的兄弟瓦片
        /// </summary>
        /// <param name="tileCode">瓦片编码</param>
        /// <param name="result">结果</param>
        /// <param name="resultCount">结果数量</param>
        /// <returns></returns>
        bool getRelativeTiles(DGGSTileCode tileCode, DGGSTileCode*&result, int &resultCount);

    };




}

_NNU_DGGS_END